<template>
  <div class="chart"></div>
</template>
      
<script>
import * as echarts from "echarts";
export default {
  name: "emperson",
  data() {
    return {
      chart: null,
    };
  },
  mounted() {
    this.$nextTick(() => {
      this.initChart();
    });
  },
  beforeDestroy() {
    if (!this.chart) {
      return;
    }
    this.chart.dispose();
    this.chart = null;
  },
  methods: {
    initChart() {
      //初始化图表
      this.chart = echarts.init(this.$el);
      //设置图表
      this.chart.setOption({
        series: [
          {
            type: "gauge",
            progress: {
              show: true,
              width: 18,
            },
            axisLine: {
              lineStyle: {
                width: 18,
              },
            },
            axisTick: {
              show: false,
            },
            splitLine: {
              length: 15,
              lineStyle: {
                width: 2,
                color: "#999",
              },
            },
            axisLabel: {
              distance: 25,
              color: "#999",
              fontSize: 20,
            },
            anchor: {
              show: true,
              showAbove: true,
              size: 25,
              itemStyle: {
                borderWidth: 10,
              },
            },
            title: {
              show: false,
            },
            detail: {
              valueAnimation: true,
              fontSize: 30,
              offsetCenter: [0, "70%"],
              formatter: "{value} 人",
            },
            data: [
              {
                value: 8,
              },
            ],
          },
        ],
      });
    },
  },
};
</script>
    <style scoped>
.chart {
  width: 500px;
  height: 450px;
}
</style>  